﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.XPath;

namespace SmartSpace.Packaging
{
    public class PublishUtility
    {
        public static string GetSiteFolder()
        {
            return @"C:\SmartSpace\web\";
        }

        public static string GetConnectionString(string siteFolder)
        {
            XDocument xDoc = XDocument.Load(Path.Combine(siteFolder, "./web.config"));

            XElement element = xDoc.XPathSelectElement("/configuration/appSettings/add[@key='ConnectionStringName']");
            string name = element.Attribute("value").Value;
            XElement stringElement = xDoc.XPathSelectElement("/configuration/connectionStrings/add[@name='" + name + "']");
            return stringElement.Attribute("connectionString").Value;
        }
    }
}
